package io;

import java.io.*;
import java.nio.charset.StandardCharsets;
import java.util.Scanner;
/**
 * 使用流连接完成PW的创建
 */
public class PWDemo2 {
    public static void main(String[] args) throws FileNotFoundException {

        FileOutputStream fos =new FileOutputStream("pwww.txt");
        OutputStreamWriter osw = new OutputStreamWriter(fos, StandardCharsets.UTF_8);
        BufferedWriter bw = new BufferedWriter(osw);
        PrintWriter pw = new PrintWriter(bw,true);
        Scanner sca= new Scanner(System.in);
        System.out.println("开始输入");
       while(true){
           String line = sca.nextLine();
           if("exit".equals(line)){
               break;
           }
           pw.println(line);
           pw.flush();
       }
        pw.close();
    }
}
